<template>
	<view class="p-10">
		<view class="card">
			<u-cell-group>
				<u-cell :title="item.title" :value="options[item.prop]" v-for="(item,index) in data"></u-cell>
			</u-cell-group>
		</view>

		<view class="card">
			<uni-table ref="table" emptyText="暂无更多数据" stripe>
				<uni-tr>
					<uni-th align="center" width="200">管控措施</uni-th>
					<uni-th align="center" width="200">工程技术措施</uni-th>
					<uni-th align="center" width="200">培训教育措施</uni-th>
					<uni-th align="center" width="200">个体防护措施</uni-th>
					<uni-th align="center" width="200">应急管理措施</uni-th>
					<uni-th align="center" width="80">责任单位</uni-th>
					<uni-th align="center" width="70">责任人</uni-th>
					<uni-th align="center" width="100">管控周期</uni-th>
					<uni-th align="center" width="200">隐患描述</uni-th>
					<uni-th align="center" width="100">隐患等级</uni-th>
				</uni-tr>
				<uni-tr v-for="(item, index) in tableData" :key="index">
					<uni-td align="center" style="fontSize: 12px !important">
						{{item.manageControlMsg}}
					</uni-td>
					<uni-td align="center" style="fontSize: 12px !important">
						{{item.technical_measure}}
					</uni-td>
					<uni-td align="center" style="fontSize: 12px !important">
						{{item.edu_measure}}
					</uni-td>
					<uni-td align="center" style="fontSize: 12px !important">
						{{item.protect_measure}}
					</uni-td>
					<uni-td align="center" style="fontSize: 12px !important">
						{{item.emergency_measure}}
					</uni-td>
					<uni-td align="center" style="fontSize: 12px !important">
						{{item.setDutyDeptName}}
					</uni-td>
					<uni-td align="center" style="fontSize: 12px !important">
						{{item.setDutyUserName}}
					</uni-td>
					<uni-td align="center" style="fontSize: 12px !important">
						{{item.manageControlDayName}}
					</uni-td>
					<uni-td align="center" style="fontSize: 12px !important">
						{{item.hiddenMsg}}
					</uni-td>
					<uni-td align="center" style="fontSize: 12px !important">
						{{item.hiddenLevelName}}
					</uni-td>
				</uni-tr>
			</uni-table>
			<view class="uni-pagination-box">
				<uni-pagination show-icon :page-size="pageSize" :current="pageCurrent" :total="total"
					@change="change" />
			</view>
		</view>

	</view>
</template>
<script setup>
	import {
		onLoad,
	} from '@dcloudio/uni-app'
	import {
		ref,
	} from 'vue'
	import {
		infoRiskData,
		getManageControlPage
	} from '@/api/riskcontrol.js'

	let options = ref({}),
		data = ref([{
			title: '风险点',
			prop: 'riskLocationName'
		}, {
			title: '项目',
			prop: 'projectInfo'
		}, {
			title: '风险类型',
			prop: 'riskTypeName'
		}, {
			title: '风险等级',
			prop: 'riskLevelName'
		}, {
			title: '风险值',
			prop: 'riskValue'
		}, {
			title: '风险描述',
			prop: 'remark'
		}]),
		tableData = ref([])

	// 每页数据量
	let pageSize = ref(10),
		// 当前页
		pageCurrent = ref(1),
		// 数据总量
		total = ref(0)

	let ids = ref('')
	// 分页触发
	const change = (e) => {
		getData(e.current)
	}

	const getData = (pageCurrent) => {
		getManageControlPage({
			pageSize: pageSize.value,
			pageNum: pageCurrent,
			id: ids.value
		}).then(res => {
			tableData.value = res.data?.rows
			total.value = res.data?.total
		})
	}
	onLoad((e) => {
		ids.value = JSON.parse(e.data).id
		infoRiskData({
			id: JSON.parse(e.data).id
		}).then(res => {
			options.value = res.data
			getData(1)
		})
	})
</script>
<style scoped>
	:deep(.u-cell__title) {
		width: 180rpx !important
	}
</style>